<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output method="xml" indent="yes"/>
 <xsl:template match="/">
  <root>
   <xsl:for-each select="//Attribute_Category_ID[not(.=following::Attribute_Category_ID)]">
   <xsl:sort select="."/> 
    <param1>   
         <Attribute_Category_ID>
        <xsl:value-of select="."/>
       </Attribute_Category_ID>
 
     <xsl:for-each select="/root/param1[Attribute_Category_ID=current()]">
     
     <!--<xsl:sort select="/root/param1[Attribute_Category_ID=current()]" order="ascending" case-order="lower-first"/>-->
     
      <AttrCatId>
       <AttributeID>
        <xsl:value-of select="AttrCatId/AttributeID"/>
       </AttributeID>
       <Attribute_Category_Value>
        <xsl:value-of select="AttrCatId/Attribute_Category_Value"/>
       </Attribute_Category_Value>
      </AttrCatId>
     </xsl:for-each>
    </param1>
   </xsl:for-each>
  </root>
 </xsl:template>
</xsl:stylesheet>
